<?php
include_once(SYSTEM.'/Model.php');
include_once(SYSTEM.'/StringLengthRule.php');
include_once(SYSTEM.'/RequiredRule.php');
include_once(SYSTEM.'/MatchRule.php');

class RegisterModel extends Model 
{	
	public $Email;
	public $Password;
	public $ConfirmPassword;
	public $FirstName;	
	public $LastName;
	public $Sex;
	public $Birthday;
	public $Captcha;
	
	public function __construct($params) 
	{							
		$this->Email = $params['email'];		
		$this->Password = $params['password'];
		$this->ConfirmPassword = $params['confirm'];
		$this->FirstName = $params['firstname'];		
		$this->LastName = $params['lastname'];
		$this->Sex = $params['sex'];
		$this->Birthday = $params['birthMonth'] . '/' . $params['birthDay'] . '/' . $params['birthYear'];
		$this->Captcha = $params['captcha'];
		
		$this->AddRules('Email', new RequiredRule('Email k duoc de trong'));
		$this->AddRules('Password', new RequiredRule('Password k duoc de trong'));
		$this->AddRules('Password', new StringLengthRule(6, 20, 'Do dai cua Password phai lon hon 6 va nho hon 20 ki tu'));
		$this->AddRules('ConfirmPassword', new RequiredRule('ConfirmPassword k duoc de trong'));
		$this->AddRules('Captcha', new RequiredRule('Captcha k duoc de trong'));
		$this->AddRules('ConfirmPassword', new MatchRule($this->Password, 'ConfirmPassword k trung voi Password'));
	}
}